nanopyx.liquid._le_template_simple

Template to implement new methods using the Liquid Engine

Template(clear_benchmarks=False, testing=False)

Initialize the Liquid Engine The Liquid Engine base class is inherited by children classes that implement specific methods

Engine responsabilities:

  1. Store implemented run types;
  2. Handle previous benchmarks and I/O;
  3. When queried, benchmark all available run types;
  4. Run a specific method using a selected run type;

Benchmark files have the following format: The benchmark file is read as dict of dicts. BENCHMARK DICT FOR A SPECIFIC METHOD |- RUN_TYPE #1 | |- ARGS_REPR #1 | | |- [score, t2run#1, t2run#2, t2run#3, ...] last are newer. nan means fail | |- ARGS_REPR #2
| | |- [score, t2run#1, t2run#2, t2run#3, ...] last are newer. nan means fail | (...) |- RUN_TYPE #2 (...)

def benchmark(self, image):
  1. Run each available run type and record the run time and return value
  2. Sort the run times from fastest to slowest
  3. Compare each run type against each other, sorted by speed
Parameters
  • args: args for the run method
  • kwargs: kwargs for the run method
Returns

a list of tuples containing the run time, run type name and optionally the return values

def run(self, image, run_type=None):

Runs the function with the given args and kwargs Should be overridden by the any class that inherits from this class